package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("ajax")
@CrossOrigin
public class UserServiceController {
    @Autowired
    private UserService userService;

    @GetMapping("findAll")
    public List<User> findAll(){
        return userService.findAll();
    }
    //增加数据
    @PostMapping("addUser")
    public void addUser(@RequestBody User user){
        userService.addUser(user);
    }
    //更新修改
    @PutMapping("updateUser")
    public void updateUser(@RequestBody User user){
        userService.updateUser(user);
    }
    //删除数据
    @DeleteMapping("deleteUser")
    public void deleteUser(Integer id){
        userService.deleteUser(id);
    }

}
